
import { Toast } from 'antd-mobile';
import axios from 'axios'
import store from '../store';
const service = axios.create({
    baseURL: "http://81.71.65.4:3003/",
    timeout: 10 * 60 * 1000
})
service.interceptors.request.use(
    config => {
        const token = store.getState('user').user.token;
        if (!(token === undefined || token === "")) {
            config.headers['user-token'] = token;
        }
        return config;
    },
    error => { return Promise.reject(error); }
)
service.interceptors.response.use(
    res => {
        if (res.data.code === 666) {
            return res;
        }
        else {
            Toast.show({
                icon: 'fail',
                content: res.data.msg
            })
            return Promise.reject(res.data.msg);
        }
    },
    error => { return Promise.reject(error); }
)
export default service;